package com.example.data.factory.web1.controller;

import com.example.data.factory.common.Dto.ClassifyBatchDto;
import com.example.data.factory.common.Dto.InserttaskDto;
import com.example.data.factory.common.Dto.SearchTaskDto;
import com.example.data.factory.common.Dto.UpdateTaskStatusDto;
import com.example.data.factory.common.result.R;
import com.example.data.factory.entity.entity.Task;
import com.example.data.factory.service.service.TaskService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lhy
 * @since 2025-03-03
 */
@RestController
@RequestMapping("/task")
@RequiredArgsConstructor
public class TaskController {
    private final TaskService taskService;

    @GetMapping("SearchTask")
    public R<Task> SearchTask(SearchTaskDto searchTaskDto) {
        return taskService.searchTask ( searchTaskDto );
    }

    @PutMapping("UpdateTaskStatus")
    public R<Task> UpdateTaskStatus(UpdateTaskStatusDto updateTaskStatusDto) {
        return taskService.updatestatus ( updateTaskStatusDto );
    }

    @PutMapping("UpdateTaskStatusBash")
    public R<Task> UpdateTaskStatusBash(@RequestBody List<UpdateTaskStatusDto> updateTaskStatusDtos) {
        return taskService.updatestatusbash ( updateTaskStatusDtos );
    }

    @PostMapping("ClassifyBash")
    public R<Map<String, String>> ClassifyBash(@RequestBody ClassifyBatchDto classifyBatchDto) {
        return taskService.classifybash ( classifyBatchDto );
    }

    @DeleteMapping("DeleteTask")
    public R<Task> deleteTask(Integer taskId) {
        return taskService.delete ( taskId );
    }

    @PostMapping("InsertTask")
    public R<Task> InsertTask(InserttaskDto inserttaskDto, HttpServletRequest request) {
        return taskService.inserttask ( inserttaskDto, request );
    }

}
